<% if(attachment != null){ %>
	<% if(_.isEmpty(attachment.attributes.link) && !_.isEmpty(attachment.attributes.name)){ %>
		<a target="_blank" href="<%= attachment.downloadLink('download', attachment.attributes.id) %>?view" class="pull-left navbar-btn img-thumbnail thumb-img">
		<% if(attachment.attributes.name.toLowerCase().match(/\.(jpg|jpeg|png|gif)$/)){ 
			var picture_path = attachment.showImage('CardAttachment', attachment.attributes.id, 'large_thumb' );
		%>
			<img src="<%= picture_path %>">
		<% } else {
			var extension = attachment.attributes.name.split('.');
		%>
			<p class="thumb-img"><%- extension[extension.length - 1].toUpperCase() %></p>
		<% } %>
		</a>
	<% } else if(!_.isEmpty(attachment.attributes.link)){ %>
		<a target="_blank" href="<%= attachment.attributes.link %>" title="<%- attachment.attributes.link %>" class="pull-left navbar-btn img-thumbnail thumb-img">
			<p class="thumb-img">
			<% if (attachment.attributes.link.indexOf("dropbox.com") > -1) {%>
				<i class="icon-dropbox"></i>
			<% } else if(attachment.attributes.link.indexOf("docs.google.com") > -1){ %>
				<i class="icon-cloud"></i>
			<% } else if(attachment.attributes.link.indexOf("github.com") > -1){ %>
				<i class="icon-github"></i>
			<% } else if(!_.isEmpty(attachment.attributes.name) && !_.isEmpty(attachment.attributes.link)) {  var extension = attachment.attributes.name.split('.'); %><% if(!_.isUndefined(extension) && extension.length > 1) { %><% if(attachment.attributes.name.toLowerCase().match(/\.(jpg|jpeg|png|gif)$/)){ %><%- extension[extension.length - 1].toUpperCase() %><% } else { %>LINK<% } } %><% }%>
			</p>
		</a>
	<% } %>
	<div class="clearfix">

		<% if(_.isEmpty(attachment.attributes.link) && !_.isEmpty(attachment.attributes.name)){ %>
			<a target="_blank" href="<%= attachment.downloadLink('download', attachment.attributes.id) %>" title="<%- attachment.attributes.name %>"><span class="htruncate col-xs-12 btn-block"><%- attachment.attributes.name %></span><span class="show btn-block col-xs-12"><%- i18next.t('Added') %> <small class="text-muted"><abbr class="timeago" title="<%- attachment.attributes.created %>"><%- attachment.attributes.created %></abbr></small></span></a>
		<% } else if(!_.isEmpty(attachment.attributes.link)){ %>
			<a target="_blank" href="<%= attachment.attributes.link %>" title="<%- attachment.attributes.link %>">
				<span class="htruncate col-xs-12 btn-block"><%- attachment.attributes.link %></span><span class="show btn-block col-xs-12"><%- i18next.t('Added') %> <small class="text-muted"><abbr class="timeago" title="<%- attachment.attributes.created %>"><%- attachment.attributes.created %></abbr></small></span>
			</a>
		<% } %>
		<%if(!_.isUndefined(authuser.user)) {%>
		<div class="btn-toolbar navbar-btn">
			<div class="btn-group btn-group-xs navbar-btn">
				<div class="btn btn-primary">	
					<% if(_.isEmpty(attachment.attributes.link)) { %> 
						<% var download_link = attachment.downloadLink('download', attachment.attributes.id); %>
						<a target="_blank" href="<%= download_link %>" title="<%- i18next.t('Download') %>">
							<i class="icon-arrow-down cur icon-light"></i>
						</a>
					<% } else { %>
						<% var link_title = 'Open in New Tab'; %>
						<% if (attachment.attributes.link.indexOf("dropbox.com") > -1) { %>
							<% link_title = 'Open in Dropbox'; %>
						<% } else if(attachment.attributes.link.indexOf("docs.google.com") > -1) { %>
							<% link_title = 'Open in Google Drive'; %>
						<% } else if(attachment.attributes.link.indexOf("github.com") > -1) { %>
							<% link_title = 'Open in Github'; %>
						<% } %>
						<a target="_blank" href="<%= attachment.attributes.link %>" title="<%- link_title %>">
							<i class="icon-external-link cur icon-light"></i>
						</a>
					<% } %>
				</div>
				<% if(!_.isUndefined(authuser.user) && (authuser.user.role_id == 1 || !_.isEmpty(board.acl_links.where({slug: "remove_card_attachment", board_user_role_id: parseInt(board.board_user_role_id)})))) { %> 
					<div class="dropdown dropdown pull-left">
						<a href="#" title="Delete" class="js-show-confirm-delete-attachment dropdown-toggle btn btn-default btn-xs" data-toggle="dropdown"><i class="icon-remove cur"></i></a>
						<ul class="dropdown-menu arrow list-unstyled">
							<li class="js-dropdown-popup js-attachment-confirm-respons-<%- attachment.id %>"></li>
						</ul>
					</div>
				<% } %>
			</div>
		</div>
		<% } %>
	</div>
<% }else{ %> 
	<span class="alert alert-info"><%- i18next.t('No %s available.', { postProcess: 'sprintf', sprintf: [i18next.t('attachments')] }) %></span>
<% } %> 